/// @file MainWindow.h
#pragma once
#include <QMainWindow>
#include <phonon/phonon>
#include <QMessageBox>
#include "build/ui_MainWindow.h"
#include "../../core/Tangram.h"
#include <gui/Trollface/Trollface.h>
#include <core/PatternManager.h>
#include <gui/Player/Player.h>
#include <gui/Scores/Scores.h>
#include <core/utility.h>
#include <gui/WinDialog/WinDialog.h>

namespace qtangram
{
    /**
      @class MainWindow
      @brief Main application's window that contains widgets.
      Fulfils controlling actions
    */
class MainWindow : public QMainWindow, private Ui_MainWindow
{
    Q_OBJECT
public:
    MainWindow(QWidget* parent = 0);
    ~MainWindow();
public slots:
    bool onCheckIfWon();
    void onMoveTanToTray();
    void onMoveTanToWorkspace();
    void onAbout();
    void onScores();
    void onPause();
    void onClose();
    void onSave();
    void onOpen();
    Clock* getClock() const { return clock; }
    void playMusic();
    void stopMusic();
    void resizeEvent (QResizeEvent* ) { trollface->rescale(); }
    void onChangeName();
    void onPositiveMatch();
    void onPatternLoaded(QLinkedList<Tan>);
    void onToleranceChange(double value);
    void onPlayerNameEntered(QString);
    void onCreationModeEntered();
    void onWinDlgOkClicked();
    void onWinDlgAgainClicked();
signals:
    void sigPositiveMatch();
private:
    void init();
    void setupConnections();
    Tangram tangram;
    Phonon::MediaObject* music;
    Trollface* trollface;
    PatternManager patternManager;
    Player* player;
    Scores* scores;
    WinDialog* winDialog;
    QPolygonF pattern;
    bool winState;
    QLinkedList<Tan> patternOriginal;
    double tol;
    bool hasPlayerName;
};
}